//
//  LSStatusCellTopView.swift
//  MicroBlog
//
//  Created by lj on 15/9/9.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit
import SDWebImage




class LSStatusCellTopView: UIView {
    
    var statusViewModel:LSStatusViewModel? {
        didSet{
            
            iconView.sd_setImageWithURL(statusViewModel?.userIconUrl)
            nameLable.text = statusViewModel?.status.user?.name
            
            //TODO: 界面数据
//            sourceLabe.text = statusViewModel?.status.source
//            timeLable.text = statusViewModel?.status.created_at
//            
        }
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
        //
        addSubview(iconView)
        addSubview(nameLable)
        addSubview(vipView)
        addSubview(timeLable)
        addSubview(sourceLabe)
        addSubview(verifiedView)
        
        //
        let offset = CGPoint(x: LSStatusCellMargin, y: 0)
        iconView.ff_AlignInner(type: ff_AlignType.TopLeft, referView: self, size: CGSize(width: LSStatusIconWidth, height: LSStatusIconWidth), offset: CGPoint(x: LSStatusCellMargin, y: LSStatusCellMargin))
        nameLable.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: iconView, size: nil, offset: offset)
        vipView.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: nameLable, size: nil, offset: offset)
        timeLable.ff_AlignHorizontal(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: offset)
        sourceLabe.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: timeLable, size: nil, offset: offset)
        verifiedView.ff_AlignInner(type: ff_AlignType.BottomRight, referView: iconView, size: CGSize(width: 15, height: 15), offset: CGPoint(x: 9 ,y: 9))
        

    }
    
    
    /// 懒加载
    private lazy var iconView:UIImageView = UIImageView(image: UIImage(named: "avatar_default_big"))
    private lazy var nameLable:UILabel = UILabel(title: "你大爷", color: UIColor.darkGrayColor(), fontSize:16)
    private lazy var vipView:UIImageView = UIImageView(image: UIImage(named: "common_icon_membership_level1"))
    private lazy var timeLable:UILabel = UILabel(title: "刚刚", color: UIColor.orangeColor(), fontSize: 12)
    private lazy var sourceLabe:UILabel =  UILabel(title: "来自你妹夫", color: UIColor.darkGrayColor(), fontSize: 14)
    private lazy var verifiedView:UIImageView = UIImageView(image: UIImage(named: "avatar_grassroot"))
    

}
